<%@ page contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
</head>
<style type="text/css">

    #msg2 {
        height: 20px;
        color: red;
    }

    .modal-content {
        margin-top: 250px;
    }

    #change_title {
        color: red;
    }

    #admin_ddgl_manage_div_detail {
        padding: 30px 50px;
    }

    #admin_ddgl_manage_div_table {
        margin-top: 15px;
    }

    #admin_ddgl_manage_div_table {
        text-align: center;
    }
</style>
<body>
<div id="admin_ddgl_manage_div" title="admin_ddgl_manage_div" style="display: none" class="row">
    <div id="admin_ddgl_manage_div_detail">
        <button type="button" class="btn btn-info">订单管理</button>
        <select id="sfjd_admin" class="form-control" onchange=adminQueryDd()>
            <option value="">全部</option>
            <option value="未接单">未接单</option>
            <option value="已接单">已接单</option>
        </select>
        <select id="ddzt_admin" class="form-control" onchange="adminQueryDd()">
            <option value="">全部</option>
            <option value="在取">在取</option>
            <option value="在洗">在洗</option>
            <option value="洗好">洗好</option>
            <option value="在送回">在送回</option>
            <option value="已经送回">已经送回</option>
        </select>
        <table id="admin_ddgl_manage_div_table" class="table table-hover">
            <thead>
            <tr style="text-align: center;">
                <th style="text-align: center;">序号</th>
                <th style="text-align: center;">客户姓名</th>
                <th style="text-align: center;">联系方式</th>
                <th style="text-align: center;">存放地点</th>
                <th style="text-align: center;">货柜号码</th>
                <th style="text-align: center;">衣服种类</th>
                <th style="text-align: center;">洗衣方法</th>
                <th style="text-align: center;">衣服数量</th>
                <th style="text-align: center;">总价格</th>
                <th style="text-align: center;">订单状态</th>
                <th style="text-align: center;">是否接单</th>
                <th style="text-align: center;">评价内容</th>
                <th style="text-align: center;">操作</th>
                <th style="text-align: center; display: none">id</th>
            </tr>
            </thead>
            <tbody id="admin_ddgl_manage_div_table_tbody">

            </tbody>
        </table>
    </div>
</div>
<div class="modal fade" id="admin_change_ddzt_model" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"/>
                <h4 class="modal-title" id="change_title">修改订单状态</h4>
            </div>
            <form id="admin_changge_ddzt_form">
                <div class="modal-body" id="change_div" style="text-align: center;">
                    <select id="ddzt_admin_select" class="form-control" style="width: 90%;">
                        <option value="在取">在取</option>
                        <option value="在洗">在洗</option>
                        <option value="洗好">洗好</option>
                        <option value="在送回">在送回</option>
                        <option value="已经送回">已经送回</option>
                    </select>
                    <div id="msg2">
                        <span class="msg2_span1"></span>
                        <span class="msg2_span2"></span>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">修改</button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    var id = 0;

    function adminChangeDdzt(obj) {
        $("#admin_change_ddzt_model").modal('show');
        id = $(obj).parent().parent().children("td:eq(13)").html();
    }

    $("#admin_changge_ddzt_form").submit(function () {
        $.ajax({
            url: "admin_change_ddzt", //请求的url地址
            contentType: "application/json; charset=utf-8",
            dataType: "json", //返回格式为json
            type: "POST", //请求方式
            data: JSON.stringify({
                'ddzt': $("#ddzt_admin_select").val(),
                'id': id
            }),
            success: function (data) {
                if (data.isSuccess) {
                    $("#admin_change_ddzt_model").modal('hide');
                    adminQueryDd();
                } else {
                    alert("状态修改失败...");
                }
            },
            error: function () {
                alert("  error  请联系开发人员 ！");
            }
        });
        return false;
    })

    function adminJd(obj) {
        $.ajax({
            url: "admin_change_jd", //请求的url地址
            contentType: "application/json; charset=utf-8",
            dataType: "json", //返回格式为json
            type: "POST", //请求方式
            data: JSON.stringify({
                'id': $(obj).parent().parent().children("td:eq(13)").html()
            }),
            success: function (data) {
                if (data.isSuccess) {
                    adminQueryDd();
                } else {
                    alert("接单失败...");
                }

            },
            complete: function () {
                //请求完成的处理
                //alert("请求完成");
            },
            error: function () {
                alert("  error  请联系开发人员 ！");
            }
        });
    }

    function adminBtnDeleteDd(obj) {
        $.ajax({
            url: "user_delete_wddd", //请求的url地址
            contentType: "application/json; charset=utf-8",
            dataType: "json", //返回格式为json
            type: "POST", //请求方式
            data: JSON.stringify({
                'id': $(obj).parent().parent().children("td:eq(13)").html(),
                'cfdd': $(obj).parent().parent().children("td:eq(3)").html(),
                'hghm': $(obj).parent().parent().children("td:eq(4)").html()
            }),
            success: function (data) {
                if (data.isSuccess) {
                    adminQueryDd();
                } else {
                    alert("删除失败...");
                }
            },
            complete: function () {
                //请求完成的处理
                //alert("请求完成");
            },
            error: function () {
                alert("  error  请联系开发人员 ！");
            }
        });
    }

    function adminQueryDd() {
        $("#admin_ddgl_manage_div").show();
        $.ajax({
            url: "query_all_dd", //请求的url地址
            contentType: "application/json; charset=utf-8",
            dataType: "json", //返回格式为json
            type: "POST",
            data: JSON.stringify({
                'sfjd': $("#sfjd_admin").val(),
                'ddzt': $("#ddzt_admin").val()
            }),
            beforeSend: function () {
            },
            success: function (data) {
                if (data.ddList.length > 0) {
                    var str = '';
                    for (var i = 0; i < data.ddList.length; i++) {
                        str += "<tr><td>" + (i + 1) + "</td><td>"
                            + data.ddList[i].userName + "</td><td>"
                            + data.ddList[i].lxfs + "</td><td>"
                            + data.ddList[i].cfdd + "</td><td>"
                            + data.ddList[i].hghm + "</td><td>"
                            + data.ddList[i].yfzl + "</td><td>"
                            + data.ddList[i].xyff + "</td><td>"
                            + data.ddList[i].yfsl + "</td><td>"
                            + data.ddList[i].zj + "</td><td>"
                            + data.ddList[i].ddzt + "</td><td>"
                            + data.ddList[i].sfjd + "</td><td>"
                            + data.ddList[i].pj + "</td><td>";
                        if (data.ddList[i].sfjd == "未接单") {
                            str += "<button type='button' class='btn btn-success' onclick='adminJd(this)'>接单</button>&nbsp;&nbsp;/&nbsp;&nbsp;<button type='button' class='btn btn-info' onclick='adminChangeDdzt(this)'>状态</button>&nbsp;&nbsp;/&nbsp;&nbsp;<button type='button' class='btn btn-danger' onclick='adminBtnDeleteDd(this)'>删除</button>"
                        } else {
                            str += "<button type='button' class='btn btn-info' onclick='adminChangeDdzt(this)'>状态</button>&nbsp;&nbsp;/&nbsp;&nbsp;<button type='button' class='btn btn-danger' onclick='adminBtnDeleteDd(this)'>删除</button>"
                        }

                        str += "</td><td style='display: none'>" + data.ddList[i].id + "</td></tr>"
                    }
                    $("#admin_ddgl_manage_div_table_tbody").html(str);
                } else {
                    $("#admin_ddgl_manage_div_table_tbody").html("没有数据");
                }
            },
            complete: function () {
                //请求完成的处理
                //alert("请求完成");
            },
            error: function (req) {
                alert("  error  请联系开发人员 ！");
            }
        });
    }

    function btnDeleteDd(obj) {
        $.ajax({
            url: "user_delete_wddd", //请求的url地址
            contentType: "application/json; charset=utf-8",
            dataType: "json", //返回格式为json
            type: "POST", //请求方式
            data: JSON.stringify({
                'id': $(obj).parent().parent().children("td:eq(12)").html(),
                'cfdd': $(obj).parent().parent().children("td:eq(1)").html(),
                'hghm': $(obj).parent().parent().children("td:eq(2)").html()
            }),
            success: function (data) {
                if (data.isSuccess) {
                    queryWddd();
                } else {
                    alert("删除失败...");
                }
            },
            complete: function () {
                //请求完成的处理
                //alert("请求完成");
            },
            error: function (req) {
                alert("  error  请联系开发人员 ！");
            }
        });
    }
</script>
</html>